﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TestApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            var t = new Timer();
            t.Tick += (o, e) =>
                {
                    if (Keyboard.FocusedElement != null)
                    {
                        Item.Content = Keyboard.FocusedElement.ToString() + " //";
                    }
                    if (UndoButton.CommandTarget != null)
                    {
                        Item.Content += UndoButton.CommandTarget.ToString();
                    }
                };
            t.Enabled = true;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var c = new Child();
            var w = new MyWindow(){Content = c};
        
            w.Show(); 
            
          //  LogicalTreeHelper.GetParent()
            w.RemoveLogicalChild(c);
            AddLogicalChild(c);
            var t = VisualTreeHelper.GetParent((DependencyObject)c);
            var b = VisualTreeHelper.GetParent(t);
   


        }
    }
}
